home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / MW MPW Binaries 1.1.1a2 / mwcPPC / MWCIncludes / sstream < prev    next >
Encoding:
Text File  |  1994-07-18  |  1.6 KB  |  72 lines  |  [TEXT/MMCC]

  1. // sstream standard header
  2. #ifndef _SSTREAM_
  3. #define _SSTREAM_
  4. #include <string>
  5. #include <strstream>
  6.  
  7. #if __MWERKS__
  8. #pragma options align=mac68k
  9. #endif
  10.  
  11.         // class stringbuf
  12. class stringbuf : public strstreambuf {
  13. public:
  14.     stringbuf(ios::openmode _W = ios::in | ios::out)
  15.         : strstreambuf(0, 0, 0, _Mode(_W)) {}
  16.     stringbuf(const string& _S,
  17.         ios::openmode _W = ios::in | ios::out)
  18.         : strstreambuf((char *)_S.c_str(), _S.length(), 0,
  19.             _Mode(_W)) {}
  20.     virtual ~stringbuf();
  21.     string str() const;
  22.     void str(const string& _S);
  23. protected:
  24.     _Strstate _Mode(ios::openmode);
  25.     };
  26.         // class istrstream
  27. class istringstream : public istream {
  28. public:
  29.     istringstream(openmode _W = in)
  30.         : ios(&_Sb), istream(&_Sb), _Sb(_W) {}
  31.     istringstream(const string& _S, openmode _W = in)
  32.         : ios(&_Sb), istream(&_Sb), _Sb(_S, _W) {}
  33.     virtual ~istringstream();
  34.     stringbuf *rdbuf() const
  35.         {return ((stringbuf *)&_Sb); }
  36.     string str() const
  37.         {return (_Sb.str()); }
  38.     void str(const string& _S)
  39.         {_Sb.str(_S); }
  40. private:
  41.     stringbuf _Sb;
  42.     };
  43.         // class ostrstream
  44. class ostringstream : public ostream {
  45. public:
  46.     ostringstream(openmode _W = out)
  47.         : ios(&_Sb), ostream(&_Sb), _Sb(_W) {}
  48.     ostringstream(const string& _S, openmode _W = out)
  49.         : ios(&_Sb), ostream(&_Sb), _Sb(_S, _W) {}
  50.     virtual ~ostringstream();
  51.     stringbuf *rdbuf() const
  52.         {return ((stringbuf *)&_Sb); }
  53.     string str() const
  54.         {return (_Sb.str()); }
  55.     void str(const string& _S)
  56.         {_Sb.str(_S); }
  57. private:
  58.     stringbuf _Sb;
  59.     };
  60.  
  61. #if __MWERKS__
  62. #pragma options align=reset
  63. #endif
  64.  
  65. #endif
  66.  
  67. /*
  68.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  69.  * Consult your license regarding permissions and restrictions.
  70.  */
  71.  
  72.